package com.sinosoft.svc.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sinosoft.svc.util.SMSUtils;


public class SendServlet extends HttpServlet {
	
    
	private static final long serialVersionUID = 1L;

	
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
   
    	doPost(request, response);
    }

    protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
    	response.setCharacterEncoding("UTF-8");
    	request.setCharacterEncoding("UTF-8");
    	PrintWriter out = response.getWriter();
    	
    	String phoneNumber = request.getParameter("phone");
    	String message = request.getParameter("message");
    	
    	if("".equals(phoneNumber)||phoneNumber == null){
    		out.write("电话号码为空"); 
    	}
    	if("".equals(message)||message == null){
    		out.write("发送内容为空");
    	}
    	
    	String resule = SMSUtils.sendMessage(phoneNumber, message);
    	//RCUtils.receiveMessageOrReport(realPath); 手动启动接收
    	out.write(resule);
    }

}
